namespace ResumableDownload.ViewModel
{
    using GalaSoft.MvvmLight;
    using GalaSoft.MvvmLight.Messaging;
    using WP7Contrib.Logging;
    using WP7Contrib.Services.Navigation;

    public abstract class ViewModelBaseWp7 : ViewModelBase
    {
        #region Constants and Fields

        protected readonly ILog Log;

        private readonly INavigationService navigationService;

        #endregion

        #region Constructors and Destructors

        protected ViewModelBaseWp7()
        {
        }

        protected ViewModelBaseWp7(IMessenger messenger)
            : base(messenger)
        {
        }

        protected ViewModelBaseWp7(INavigationService navigationService, ILog log)
        {
            this.navigationService = navigationService;
            this.Log = log;
        }

        protected ViewModelBaseWp7(INavigationService navigationService, IMessenger messenger, ILog log)
            : base(messenger)
        {
            this.navigationService = navigationService;
            this.Log = log;
        }

        #endregion

        #region Properties

        public INavigationService NavigationService
        {
            get
            {
                return this.navigationService;
            }
        }

        #endregion

        protected void SetPropertyAndNotify<T>(ref T currentValue, T newValue, string proertyName)
        {
            if (Equals(currentValue, newValue))
            {
                return;
            }

            currentValue = newValue;
            this.RaisePropertyChanged(proertyName);
        }
    }
}
